<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>修改百度云链接_资源共享平台</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <style type="text/css">
        .layui-container {
            max-width: 600px;
            margin-top: 50px;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <form class="layui-form" name="myForm" method="post">
        <input id="id" type="hidden" name="id" />
        <div class="layui-form-item">
            <label class="layui-form-label">链接：</label>
            <div class="layui-input-block">
                <input type="text" name="downloadUrl" class="layui-input" lay-verify="required" lay-reqText="请输入百度云分享地址" placeholder="请输入百度云分享地址" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-block">
                <input type="text" name="downloadPass" class="layui-input" lay-verify="required" lay-reqText="请输入密码" placeholder="请输入密码" />
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="*">提交</button>
                &nbsp;&nbsp;<label id="errorInfo" style="color: red;"></label>
            </div>
        </div>
    </form>
</div>

<script src="/layui/layui.js"></script>
<script type="text/javascript" th:inline="javascript">
    layui.use(['layer', 'form', 'element'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            form = layui.form;

        // 监听提交
        form.on('submit(*)', function (data) {
            $.post("/res/updateShareLink", data.field, function (result) {
                if (result.success) {
                    layer.alert("提交成功！", function (index) {
                        parent.layer.closeAll();
                    });
                } else {
                    $("#errorInfo").text(result.errorInfo);
                }
            }, "json");
            return false;
        });
    });
</script>
</body>
</html>